
package model;


import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;

public class MembuatTabel {

    public static void main(String[] args) {
// jdbc:oracle:thin merupaka jenis JDBC
// angka 172.23.9.185 merupakan IP server oracle
// angka 1521 menunjukkan port server Oracle yang bisa diakses
// orcl merupakan nama listener server database oracle
//        String jdbcUrl = "jdbc:oracle:thin:@172.23.9.185:1521:orcl";
        String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
        String userid = "MHS115314089";
        String password = "MHS115314089";
        Connection conn;
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi is OK");
            String sql = "CREATE table \"USER\" (\"ID_USER\" VARCHAR2(10) NOT NULL,"
                    + "\"NAMA\" VARCHAR2(100) NOT NULL,"
                    + "constraint \"USER_PK\" primary key (\"ID_USER\") ENABLE  )";
            Statement statement = conn.createStatement();
            statement.executeUpdate(sql);
            sql = "CREATE TABLE \"SURATDOKUMEN\"(\"ID_SRTDOK\" VARCHAR2(10),"
                    + "\"TGL_TERIMA\" DATE,"
                    + "\"NO_SURAT\" VARCHAR2(40),"
                    + "\"NO_DOKUMEN\" VARCHAR2(40),"
                    + "\"PRIHAL\" VARCHAR2(100),"
                    + "\"PENGIRIM\" VARCHAR2(100),"
                    + "\"PENERIMA\" VARCHAR2(100),"
                    + "\"TANGGAL_TERIMA\" DATE,"
                    + "\"PETUGAS_PENERIMA\" VARCHAR2(100),"
                    + "\"TEMPAT_PENYIMPANAN\" VARCHAR2(100),"
                    + "CONSTRAINT \"SURATDOKUMEN_PK\" PRIMARY KEY (\"ID_SRTDOK\") ENABLE)";
            statement.executeUpdate(sql);
//            sql = "CREATE TABLE \"DOKUMEN\"(\"ID_DOKUMEN\" VARCHAR2(10),"
//                    + "\"TANGGAL_DOKUMEN\" DATE,"
//                    + "\"NOMOR_DOKUMEN\" VARCHAR2(40),"
//                    + "\"PRIHAL\" VARCHAR2(200),"
//                    + "\"PENGIRIM\" VARCHAR2(100),"
//                    + "\"PENERIMA\" VARCHAR2(100),"
//                    + "\"PETUGAS_PENERIMA\" VARCHAR2(100),"
//                    + "\"TANGGAL_TERIMA\" DATE,"
//                    + "\"TEMPAT_PENYIMPANAN\" VARCHAR2(100),"
//                    + "CONSTRAINT \"DOKUMEN_PK\" PRIMARY KEY (\"ID_DOKUMEN\") ENABLE)";
//            statement.executeUpdate(sql);
        } catch (SQLException e) {

            System.out.println("error :" + e.getMessage());
        }
    }
}